package com.fifth.user.controller;

import com.fifth.common.pojo.dto.CommonResult;
import com.fifth.common.pojo.entity.Addr;
import com.fifth.user.service.AddrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 第五组
 * @since 2022-09-02
 */
@RestController
@RequestMapping("user/addr")
public class AddrController {
    @Autowired
    private AddrService addrService;

    //添加收货地址
    @PostMapping("insertAddr")
    public CommonResult insertAddr(@RequestBody Addr addr){
        return addrService.insertAddr(addr);
    }
    //查询收货地址
    @PostMapping("findByUId/{uid}")
    public CommonResult findByUid(@PathVariable String uid){
        return addrService.findByUid(uid);
    }
    //修改收货地址
    @PostMapping("updateById")
    public CommonResult updateById(@RequestBody Addr addr){
        return addrService.updateById(addr);
    }
    //逻辑删除收货地址
    @GetMapping("deleteById")
    public CommonResult deleteById(String id){
        return addrService.deleteById(id);
    }
    //查询个人收货地址
    @GetMapping("findAll")
    public CommonResult findAll(){
        return addrService.findAll();
    }


}
